<?php defined('SYSPATH') or die('No direct script access.');
/**
 * Acts as an object wrapper for HTML pages with embedded PHP, called "views".
 * Variables can be assigned with the view object and referenced locally within
 * the view.
 *
 * @package    Smarty3
 * @author     Mr Anchovy
 * @copyright  (c) 2011 Mr Anchovy
 * @license    http://kohanaframework.org/license
 */
class Json_View {
	
	private $data = array();
	
	public function __construct(array $data = NULL) {
		$this->data = $data;
	}
	
	public static function factory(array $data){
		return new Json_View($data);
	}
	
	public function __toString() {
		$request = Request::current();
		$request->headers('Content-Type', 'application/json');
		return json_encode($this->data);
	}
}